984A - Game - CodeForces Solution


sortings *800

Please click on ads to support us..

Python Code:

k=int(input())
L=list(map(int,input().split()))
L.sort()
for i in range(k):
	if len(L)==1:
		break
	elif i%2==0:
		del L[len(L)-1]
	else:
		del L[0]
print(L[0])

C++ Code:

#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	int num[100001];
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> num[i];
	}
	sort(num, num + n);
	int t = n % 2 == 0 ? n / 2 - 1 : n / 2;
	cout << num[t];
}
					   	   					 	  		  	 		


Comments

Submit
0 Comments
More Questions

1000B - Light It Up
218B - Airport
1463B - Find The Array
1538C - Number of Pairs
621B - Wet Shark and Bishops
476B - Dreamoon and WiFi
152C - Pocket Book
1681D - Required Length
1725D - Deducing Sortability
1501A - Alexey and Train
721B - Passwords
1263D - Secret Passwords
1371B - Magical Calendar
1726E - Almost Perfect
1360C - Similar Pairs
900A - Find Extra One
1093D - Beautiful Graph
748A - Santa Claus and a Place in a Class
1511B - GCD Length
676B - Pyramid of Glasses
597A - Divisibility
1632A - ABC
1619D - New Year's Problem
242B - Big Segment
938A - Word Correction
159C - String Manipulation 10
258A - Little Elephant and Bits
1536C - Diluc and Kaeya
1428C - ABBB
1557A - Ezzat and Two Subsequences